/**
 * createRouter 这个为创建路由的方法
 * createWebHashHistory 这个就是vue2中路由的模式，
 *                      这里的是hash模式，这个还可以是createWebHistory等
 * RouteRecordRaw 这个为要添加的路由记录，也可以说是routes的ts类型
 */
import { createRouter, createWebHashHistory, RouteRecordRaw } from "vue-router";
// 路由记录，这个跟vue2中用法一致，就不做过多解释了
const routes: Array<RouteRecordRaw> = [
  {
    path: "/",
    name: "Home",
    component: () => import("@/pages/Home.vue"),
    alias: "/home",
    meta: {
      title: "主页页面",
    },
    children: [
      {
        path: "",
        name: "Goods",
        component: () => import("@/components/goods/Goods.vue"),
        alias: "/goods",
        meta: {
          title: "商品页面",
        },
      },
      {
        path: "kitchen",
        name: "Kitchen",
        component: () => import("@/components/kitchen/Kitchen.vue"),
        alias: "/kitchen",
        meta: {
          title: "自在厨房",
        },
      },
      {
        path: "about",
        name: "About",
        component: () => import("@/components/about/About.vue"),
        alias: "/about",
        meta: {
          title: "关于我们",
        },
      },
    ],
  },
  {
    path: "/order",
    name: "Order",
    component: () => import("@/pages/Order.vue"),
    alias: "/order",
    meta: {
      title: "订单页面",
    },
  },
];

const router = createRouter({
  history: createWebHashHistory(),
  routes,
});
export default router;
